package com.aorise.controller.diagnosis;

import com.aorise.exception.ServiceException;
import com.aorise.model.diagnosis.*;
import com.aorise.service.diagnosis.DiagnosisPlanService;
import com.aorise.utils.ConstDefine;
import com.aorise.utils.StatusDefine;
import com.aorise.utils.StatusDefineMessage;
import com.aorise.utils.json.JsonResponseData;
import com.aorise.utils.page.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:cat
 * @Desicription: 视频质量诊断任务控制器类
 * @Date:Created in 2019-06-24
 * @Modified By:
 */
@RestController
@Api(description = "视频质量诊断任务信息接口")
public class DiagnosisPlanController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private DiagnosisPlanService diagnosisPlanService;

    /**
     * 查询所有自动诊断任务信息
     * HTTP 方式：GET
     * API 路径：/api/diagnosisPlan
     * 方法名：getAllDiagnosisPlanListByPage
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "查询所有自动诊断任务信息", httpMethod = "GET", response = String.class, notes = "查询所有自动诊断任务信息,提供视频质量诊断-自动巡检配置-查询列表使用")
    @RequestMapping(value = "/api/diagnosisPlan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getAllAutoDiagnosisPlan() {
        logger.debug("Request RESTful API:getAllDiagnosisPlan");

        try {
            List<DiagnosisPlanModel> diagnosisPlanModels = diagnosisPlanService
                    .getAllAutoDiagnosisPlan();

            return new JsonResponseData(true, StatusDefineMessage.GetMessage(StatusDefine.SUCCESS),
                    StatusDefine.SUCCESS, "", diagnosisPlanModels).toString();
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getAllDiagnosisPlanListByPage...msg:Get DiagnosisPlan List DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getAllDiagnosisPlanListByPage...msg:Get DiagnosisPlan List Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 根据条件查询诊断任务详情
     * HTTP 方式：GET
     * API 路径：/api/diagnosisPlan/getDiagnosisPlanById
     * 方法名：getDiagnosisPlanById
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "根据条件查询诊断任务详情", httpMethod = "GET", response = String.class,
            notes = "根据ID，创建人ID查询诊断任务详情，提供视频质量诊断-人工巡检、自动巡检配置-查询诊断任务详情使用。" +
                    "如果查的是自动巡检只需填写ID，如果是人工巡检则填写创建人ID")
    @RequestMapping(value = "/api/diagnosisPlan/getDiagnosisPlanById", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getDiagnosisPlanById(@ApiParam(value = "ID", required = false) @RequestParam(value = "id", required = false) Integer id,
                                       @ApiParam(value = "创建人ID", required = false) @RequestParam(value = "createUser", required = false) Integer createUser) {

        logger.debug("Request RESTful API:getDiagnosisPlanById");
        logger.debug("id" + id);
        logger.debug("createUser" + createUser);
        try {
            DiagnosisPlanModel diagnosisPlanModel = diagnosisPlanService
                    .getDiagnosisByIdCreateUser(id, createUser);
            return new JsonResponseData(true, StatusDefineMessage.GetMessage(StatusDefine.SUCCESS),
                    StatusDefine.SUCCESS, "", diagnosisPlanModel).toString();
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getDiagnosisPlanById...msg:Get Diagnosis Plan By Id DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getDiagnosisPlanById...msg:Get Diagnosis Plan By Id Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 更新人工诊断任务信息
     * HTTP 方式：POST
     * API 路径：/api/diagnosisPlan/updateArtificialDiagnosisPlan
     * 方法名：UpdateArtificialDiagnosisPlan
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "更新人工诊断任务信息", httpMethod = "POST", response = String.class, notes = "更新人工诊断任务信息，提供视频质量诊断-人工巡检-保存诊断任务详情使用")
    @RequestMapping(value = "/api/diagnosisPlan/updateArtificialDiagnosisPlan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody
    String updateArtificialDiagnosisPlan(@ApiParam(value = "任务名称", required = true) @RequestParam(value = "pName", required = true) String pName,
                                         @ApiParam(value = "操作人ID", required = true) @RequestParam(value = "createUser", required = true) Integer createUser,
                                         @ApiParam(value = "设备ID（逗号分隔）", required = true) @RequestParam(value = "cameraIds", required = true) String cameraIds,
                                         @ApiParam(value = "是否执行：1是，2否", required = true) @RequestParam(value = "isRun", required = true) Integer isRun,
                                         @RequestBody @Validated List<DiagnosisParamAddVO> diagnosisParamAddVOS,
                                         BindingResult result) {

        logger.debug("Request RESTful API:UpdateArtificialDiagnosisPlan");
        logger.debug("pName：" + pName);
        logger.debug("createUser：" + createUser);
        logger.debug("cameraIds：" + cameraIds);
        logger.debug("diagnosisParamAddVOS：" + diagnosisParamAddVOS);
        logger.debug("isRun：" + isRun);

        try {
            if (result.hasErrors()) {
                return JsonResponseData.ofMessage(StatusDefine.DATA_FORMAT_ERROR,
                        result.getFieldError().getDefaultMessage());
            }
            int ret = diagnosisPlanService.updateArtificialDiagnosisPlan(pName, createUser,
                    cameraIds, diagnosisParamAddVOS, isRun);

            if (ret > 0) {
                return new JsonResponseData(true,
                        StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                        ret).toString();
            } else {
                return new JsonResponseData(false, "", StatusDefine.FAILURE,
                        StatusDefineMessage.GetMessage(StatusDefine.FAILURE), "").toString();
            }
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:UpdateArtificialDiagnosisPlan...msg:Update Artificial Diagnosis Plan DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (ServiceException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:UpdateArtificialDiagnosisPlan...msg:Update Artificial Diagnosis Plan ServiceException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.CAMERA_NULL, e.getMessage(), null)
                    .toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:UpdateArtificialDiagnosisPlan...msg:Update Artificial Diagnosis Plan Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 更新自动诊断任务信息
     * HTTP 方式：PUT
     * API 路径：/api/diagnosisPlan/updateAutoDiagnosisPlan
     * 方法名：updateAutoDiagnosisPlan
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "更新自动诊断任务信息", httpMethod = "PUT", response = String.class, notes = "更新自动诊断任务信息，提供视频质量诊断-自动巡检配置-编辑诊断任务详情使用")
    @RequestMapping(value = "/api/diagnosisPlan/updateAutoDiagnosisPlan", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody
    String updateAutoDiagnosisPlan(@RequestBody @Validated DiagnosisPlanEditVO diagnosisPlanEditVO,
                                   BindingResult result,
                                   @ApiParam(value = "设备ID（逗号分隔）", required = true) @RequestParam(value = "cameraIds", required = true) String cameraIds) {

        logger.debug("Request RESTful API:updateAutoDiagnosisPlan");
        logger.debug("diagnosisPlanEditVO：" + diagnosisPlanEditVO);
        logger.debug("cameraIds：" + cameraIds);

        try {
            if (result.hasErrors()) {
                return JsonResponseData.ofMessage(StatusDefine.DATA_FORMAT_ERROR,
                        result.getFieldError().getDefaultMessage());
            }
            int ret = diagnosisPlanService.updateAutoDiagnosisPlan(diagnosisPlanEditVO,
                    diagnosisPlanEditVO.getDiagnosisParamAddVOS(), cameraIds);

            if (ret > 0) {
                return new JsonResponseData(true,
                        StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                        "").toString();
            } else {
                return new JsonResponseData(false, "", StatusDefine.FAILURE,
                        StatusDefineMessage.GetMessage(StatusDefine.FAILURE), "").toString();
            }
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlan...msg:Update Auto Diagnosis Plan DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (ServiceException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlan...msg:Update Auto Diagnosis Plan ServiceException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.CAMERA_NULL, e.getMessage(), null)
                    .toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlan...msg:Update Auto Diagnosis Plan Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 新增自动诊断任务信息
     * HTTP 方式：POST
     * API 路径：/api/diagnosisPlan
     * 方法名：addDiagnosisPlan
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "新增自动诊断任务信息", httpMethod = "POST", response = String.class, notes = "新增自动诊断任务信息，提供视频质量诊断-自动巡检配置-新增自动诊断任务使用")
    @RequestMapping(value = "/api/diagnosisPlan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody
    String addAutoDiagnosisPlan(@RequestBody @Validated DiagnosisPlanAddVO diagnosisPlanAddVO,
                                BindingResult result,
                                @ApiParam(value = "设备ID（逗号分隔）", required = true) @RequestParam(value = "cameraIds", required = true) String cameraIds) {

        logger.debug("Request RESTful API:addAutoDiagnosisPlan");
        logger.debug("diagnosisPlanAddVO：" + diagnosisPlanAddVO);
        logger.debug("cameraIds：" + cameraIds);

        try {
            if (result.hasErrors()) {
                return JsonResponseData.ofMessage(StatusDefine.DATA_FORMAT_ERROR,
                        result.getFieldError().getDefaultMessage());
            }
            int ret = diagnosisPlanService.addAutoDiagnosisPlan(diagnosisPlanAddVO,
                    diagnosisPlanAddVO.getDiagnosisParamAddVOS(), cameraIds);

            if (ret > 0) {
                return new JsonResponseData(true,
                        StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                        ret).toString();
            } else {
                return new JsonResponseData(false, "", StatusDefine.FAILURE,
                        StatusDefineMessage.GetMessage(StatusDefine.FAILURE), "").toString();
            }
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:addAutoDiagnosisPlan...msg:Add Auto Diagnosis Plan DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (ServiceException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:addAutoDiagnosisPlan...msg:Add Auto Diagnosis Plan ServiceException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.CAMERA_NULL, e.getMessage(), null)
                    .toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:addAutoDiagnosisPlan...msg:Add Auto Diagnosis Plan Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 删除自动诊断任务信息
     * HTTP 方式：DELETE
     * API 路径：/api/diagnosisPlan/id/{id}
     * 方法名：deleteDiagnosisPlan
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "删除自动诊断任务信息", httpMethod = "DELETE", response = String.class, notes = "删除自动诊断任务信息，提供视频质量诊断-自动巡检配置-删除自动诊断任务使用")
    @RequestMapping(value = "/api/diagnosisPlan/id/{id}", method = RequestMethod.DELETE, produces = "application/json")
    public String deleteDiagnosisPlan(@ApiParam(value = "ID", required = true) @PathVariable(value = "id", required = true) Integer id,
                                      @ApiParam(value = "修改人ID", required = true) @RequestParam(value = "editUser", required = true) Integer editUser) {
        logger.debug("Request RESTful API:deleteDiagnosisPlan");
        logger.debug("id" + id);
        logger.debug("editUser" + editUser);

        try {
            Map<String, Object> map = new HashMap<>();
            map.put("editUser", editUser);
            map.put("pType", ConstDefine.DIAGNOSIS_PLAN_AUTO);
            map.put("state", ConstDefine.STATE_DISABLE);
            map.put("id", id);
            int ret = diagnosisPlanService.deleteDiagnosisPlan(map);

            if (ret > 0) {
                return new JsonResponseData(true,
                        StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                        "").toString();
            } else {
                return new JsonResponseData(false, "", StatusDefine.FAILURE,
                        StatusDefineMessage.GetMessage(StatusDefine.FAILURE), "").toString();
            }
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:deleteDiagnosisPlan...msg:Delete Diagnosis Plan DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (ServiceException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:deleteDiagnosisPlan...msg:Delete Diagnosis Plan ServiceException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DIAGNOSIS_RUNNING, e.getMessage(),
                    null).toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:deleteDiagnosisPlan...msg:Delete Diagnosis Plan Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 开启关闭自动诊断任务信息
     * HTTP 方式：POST
     * API 路径：/api/diagnosisPlan/updateAutoDiagnosisPlanIsOpen
     * 方法名：doLikeDiagnosisPlan
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-24
     */
    @ApiOperation(value = "开启关闭自动诊断任务信息", httpMethod = "POST", response = String.class, notes = "开启关闭自动诊断任务信息，提供视频质量诊断-自动巡检配置-开启关闭自动诊断任务使用")
    @RequestMapping(value = "/api/diagnosisPlan/doLikeDiagnosisPlan", method = RequestMethod.POST, produces = "application/json")
    public String updateAutoDiagnosisPlanIsOpen(@ApiParam(value = "ID", required = true) @RequestParam(value = "id", required = true) Integer id,
                                                @ApiParam(value = "修改状态：1开启，2关闭", required = true) @RequestParam(value = "isOpen", required = true) Integer isOpen,
                                                @ApiParam(value = "修改人", required = true) @RequestParam(value = "editUser", required = true) Integer editUser) {
        logger.debug("Request RESTful API:updateAutoDiagnosisPlanIsOpen");
        logger.debug("id" + id);
        logger.debug("isOpen" + isOpen);
        logger.debug("editUser" + editUser);

        try {
            Map<String, Object> map = new HashMap<>();
            map.put("id", id);
            map.put("isOpen", isOpen);
            map.put("editUser", editUser);
            map.put("pType", ConstDefine.DIAGNOSIS_PLAN_AUTO);
            map.put("state", ConstDefine.STATE_ABLE);
            int ret = diagnosisPlanService.updateAutoDiagnosisPlanIsOpen(map);

            if (ret > 0) {
                return new JsonResponseData(true,
                        StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                        "").toString();
            } else {
                return new JsonResponseData(false, "", StatusDefine.FAILURE,
                        StatusDefineMessage.GetMessage(StatusDefine.FAILURE), "").toString();
            }
        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlanIsOpen...msg:Update Auto Diagnosis Plan Is Open DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (ServiceException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlanIsOpen...msg:Update Auto Diagnosis Plan Is Open ServiceException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DIAGNOSIS_RUNNING, e.getMessage(),
                    null).toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:updateAutoDiagnosisPlanIsOpen...msg:Update Auto Diagnosis Plan Is Open Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 查询视频诊断队列任务数量
     * HTTP 方式：GET
     * API 路径：/api/diagnosisPlan/getDiagnosisMQSum
     * 方法名：getDiagnosisMQ
     * 方法返回类型：String
     *
     * @Author: cat
     * @Date: 2019-06-25
     */
    @ApiOperation(value = "查询视频诊断队列任务数量", httpMethod = "GET", response = String.class, notes = "查询视频诊断队列任务数量,提供视频质量诊断-人工巡检、诊断报告-查询是否有正在执行的任务使用")
    @RequestMapping(value = "/api/diagnosisPlan/getDiagnosisMQSum", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getDiagnosisMQSum() {
        logger.debug("Request RESTful API:getDiagnosisMQSum");

        try {
            List<DiagnosisMQModel> diagnosisMQModels = diagnosisPlanService.getDiagnosisMQ();

            return new JsonResponseData(true,
                    StatusDefineMessage.GetMessage(StatusDefine.SUCCESS), StatusDefine.SUCCESS, "",
                    diagnosisMQModels.size()).toString();

        } catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getDiagnosisMQSum...msg:Get DiagnosisMQ Sum DataAccessException. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.DB_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.DB_ERROR), null).toString();
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getDiagnosisMQSum...msg:Get DiagnosisMQ Sum Exception. error:"
                            + e.getMessage());
            logger.error("error:" + e.getMessage());
            return new JsonResponseData(false, "", StatusDefine.SYS_ERROR,
                    StatusDefineMessage.GetMessage(StatusDefine.SYS_ERROR), null).toString();
        }
    }

    /**
     * 每小时查询是否有要执行的自动巡检任务
     * @Author: cat
     * @Date: 2019-06-25
     */
    //@Scheduled(cron = "0 */1 * * * ?")
    @Scheduled(cron = "0 0 */1 * * ? ")
    private void getRunDiagnosis(){
        try {
            logger.info("每小时查询是否有要执行的自动巡检任务开始,当前时间为: {}",new Date());
            diagnosisPlanService.getRunDiagnosis();
            logger.info("每小时查询是否有要执行的自动巡检任务结束,当前时间为: {}",new Date());
        }catch (DataAccessException e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getRunDiagnosis...msg: Get Run Diagnosis DataAccessException");
            logger.error("error:" + e.getMessage());
        } catch (Exception e) {
            logger.error(
                    "controller:DiagnosisPlanController. function:getRunDiagnosis... msg:Get Run Diagnosis Exception");
            logger.error(e.getMessage());
        }
    }

}
